﻿<UserControl x:Class="VSTalk.Engine.View.ClientEditorControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:w="clr-namespace:VSTalk.Engine.Utils"
             xmlns:interactivity="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:converters="clr-namespace:VSTalk.Engine.Converters"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300">
    <Grid Height="Auto">
        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.Resources>
            <converters:ButtonTitleConverter x:Key="ButtonTitleConverter"/>
        </Grid.Resources>
        <Label Grid.Row="0"
               Grid.Column="0"
               Content="Username" />
        <TextBox Grid.Row="0"
                 Grid.Column="1"
                 Margin="2"
                 ToolTip="xxx for xxx@gmail.com"
                 Text="{Binding Client.Login, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                 IsEnabled="{Binding IsDisconnected, Mode=OneWay}"/>

        <Label Grid.Row="1"
               Grid.Column="0"
               Content="Password" />
        <PasswordBox Grid.Row="1"
                     Grid.Column="1"
                     Margin="2"
                     PasswordChar="*"
                     w:PasswordHelper.Attach="True"
                     w:PasswordHelper.Password="{Binding Client.Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
        <Label Grid.Row="2"
               Grid.Column="0"
               Content="Server" />
        <TextBox Grid.Row="2"
                 Grid.Column="1"
                 Margin="2"
                 ToolTip="gmail.com for xxx@gmail.com"
                 Text="{Binding Client.Server, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                 IsEnabled="{Binding IsDisconnected, Mode=OneWay}"/>
        <StackPanel Grid.Row="3"
                    Grid.Column="0"
                    Grid.ColumnSpan="2"
                    Orientation="Horizontal"
                    HorizontalAlignment="Center">
            <Button Content="{Binding IsEditing, Converter={StaticResource ButtonTitleConverter}}"
                    Margin="5"
                    Command="{Binding SaveChanges}">
            </Button>
            <Button Content="Cancel"
                    Margin="5"
                    IsCancel="True"
                    Command="{Binding RejectChanges}" />
        </StackPanel>
    </Grid>

</UserControl>
